<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/12/05/0005
 * Time: 8:58
 */

namespace app\sports_admin\model;


use think\Model;
use traits\model\SoftDelete;

class PlanType extends Model
{
    use SoftDelete;
    protected $table = 'plan_type';

    protected $pk = 'id';

    protected $autoWriteTimestamp = true;

    protected $hidden = ['create_time','update_time'];

    //获取分类
    public static function getPlayTypeList()
    {
        //return self::field('id,title,parent_id,sort,path,concat(path,id,create_time)as type')->order('type')->select();
        return self::order('level')->order('sort')->select();
    }

    public static function getInfo($id)
    {
        return self::where('parent_id',$id)->select();
    }
    /**
     * 查询是否有子类
     * @param $id 父类id
     */
    public static function getTypeChild($id)
    {
        return self::field('id,path,title,concat(path,id) as type,parent_id')->where('parent_id',$id)->find();
    }
    /*
     * 查询父类信息
     * @param $id 父类id
     */
    public static function getTypeParentInfo($id)
    {
        return self::field('id,title')->where('id',$id)->find();
    }
}